<script setup lang="ts">
import { onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useHospitalStore } from '@/store/modules/hospital'
import { storeToRefs } from 'pinia'

const useHospital = useHospitalStore()
const { hospitalMenu } = storeToRefs(useHospital)
const $router = useRouter()
const $route = useRoute()

// 请求数据

const { hoscode } = $route.query
// 请求数据
const fetchRegisterData = (hoscode: string) => {
  useHospital.fetchHospitalResgiterAction(hoscode)
}
// 请求科室数据
const fetchDepartData = (hoscode: string) => {
  useHospital.fetchHospitalDepartmentAction(hoscode)
}

onMounted(() => {
  useHospital.fetchHospitalMenu()
  fetchRegisterData(hoscode as string)
  fetchDepartData(hoscode as string)
})
const menuItemClickHandle = (path: string) => {
  $router.push({
    path: '/hospital/' + path,
    query: {
      hoscode
    }
  })
}
</script>
<template>
  <div class="hospital">
    <PageMenu
      :route-arr="hospitalMenu"
      @menu-item-click-handle="menuItemClickHandle"
    ></PageMenu>
  </div>
</template>
<style scoped lang="less"></style>
